package com.jiyi.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseExpandableListAdapter;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.jiyi.bean.maintenance.DetectItemParent;
import com.jiyi.bean.maintenance.DetectSystemJson.Equipment;
import com.jiyi.widget.MultiLineRadioGroup;
import com.jiyi.widget.picselect.PicsAdapter;
import com.jiyi.widget.picshow.ImagePagerActivity;
import com.swift.maintenance.R;
import com.swift.utils.DateUtils;
import com.swift.utils.DeviceUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zlw
 */
public class DetectItemReadAdapter extends BaseExpandableListAdapter {
	private Context mContext;
	ArrayList<DetectItemParent> mList = new ArrayList<DetectItemParent>();
	LayoutInflater inflater;
	private InputMethodManager imm;
	private final int TYPE_0 = 0;
	private final int TYPE_1 = 1;
	private final int TYPE_2 = 2;
	private final int TYPE_3 = 3;
	private final int TYPE_4 = 4;
	private final int TYPE_5 = 5;
	private int catePosition;

	public DetectItemReadAdapter(Context context, int position,
			ArrayList<DetectItemParent> liveList) {
		this.mContext = context;
		this.catePosition = position;
		this.mList = liveList;
		imm = DeviceUtil.getInstance().getImm();
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getGroupCount() {
		return mList.size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		int childSize = mList.get(groupPosition).getChildList().size();
		return childSize;
	}

	@Override
	public Object getGroup(int i) {
		return getGroup(i);
	}

	@Override
	public Object getChild(int i, int i1) {
		return getChild(i, i1);
	}

	@Override
	public long getGroupId(int i) {
		return i;
	}

	@Override
	public long getChildId(int i, int i1) {
		return i1;
	}

	@Override
	public boolean hasStableIds() {
		return false;
	}

	@Override
	public View getGroupView(final int position, boolean isExpanded,
			View convertView, ViewGroup viewGroup) {
		GroupHolder groupHolder;
		if (convertView == null) {
			convertView = View.inflate(mContext,
					R.layout.item_detect_item_head, null);
			groupHolder = new GroupHolder(convertView);
			convertView.setTag(groupHolder);
		} else {
			groupHolder = (GroupHolder) convertView.getTag();
		}
		groupHolder.mGroupTitleTv.setText(mList.get(position).getTitle());

		boolean isFinish = false;
		for (int i = 0; i < mList.get(position).getChildList().size(); i++) {
			Equipment detectItem = mList.get(position).getChildList().get(i);
			if (detectItem.getWithout() == 1
					|| detectItem.getImageList().size() > 0) {
				isFinish = true;
				break;
			}
		}
		if (isFinish) {
			groupHolder.tvMore.setText("此项已操作");
		} else {
			groupHolder.tvMore.setText("");
		}

		boolean isError = false;
		for (int i = 0; i < mList.get(position).getChildList().size(); i++) {
			Equipment detectItem = mList.get(position).getChildList().get(i);
			if (!TextUtils.isEmpty(detectItem.getFault())
					&& detectItem.getFault().equals("1")) {
				isError = true;
				break;
			}
		}

		Drawable defaultDraw = mContext.getResources().getDrawable(
				R.drawable.detectitem_head_tip);
		defaultDraw.setBounds(0, 0, defaultDraw.getMinimumWidth(),
				defaultDraw.getMinimumHeight());
		if (isError) {
			// 根据有异常的项，来对头部进行标志处理
			Drawable errorDraw = mContext.getResources().getDrawable(
					R.mipmap.icon_error_tip);
			errorDraw.setBounds(0, 0, errorDraw.getMinimumWidth(),
					errorDraw.getMinimumHeight());
			groupHolder.mGroupTitleTv.setCompoundDrawables(defaultDraw, null,
					errorDraw, null);
		} else {
			groupHolder.mGroupTitleTv.setCompoundDrawables(defaultDraw, null,
					null, null);
		}

		if (isExpanded) {
			Drawable searchDraw = mContext.getResources().getDrawable(
					R.mipmap.icon_extend);
			searchDraw.setBounds(0, 0, searchDraw.getMinimumWidth(),
					searchDraw.getMinimumHeight());
			groupHolder.tvMore.setCompoundDrawables(null, null, searchDraw,
					null);
		} else {
			Drawable searchDraw = mContext.getResources().getDrawable(
					R.mipmap.icon_extend);
			searchDraw.setBounds(0, 0, searchDraw.getMinimumWidth(),
					searchDraw.getMinimumHeight());
			groupHolder.tvMore.setCompoundDrawables(null, null, searchDraw,
					null);
		}

		return convertView;
	}

	@Override
	public View getChildView(final int groupPosition, final int childPosition,
			boolean b, View convertView, ViewGroup viewGroup) {
		DetectItemParent detectItemParent = mList.get(groupPosition);
		Equipment detectItem = detectItemParent.getChildList().get(
				childPosition);
		int type = getChildType(groupPosition, childPosition);
		// 图片列表
		List<String> picList = (List<String>) detectItem.getImageList();
		switch (type) {
		case TYPE_0:
			// 有当前状态的选择按钮
			final ChildHolderZore childHolderZore;
			if (convertView == null) {
				convertView = inflater.inflate(
						R.layout.item_detect_self_test_read, viewGroup, false);
				childHolderZore = new ChildHolderZore(convertView);
				convertView.setTag(childHolderZore);
			} else {
				childHolderZore = (ChildHolderZore) convertView.getTag();
			}
			childHolderZore.tvDetectTitle.setText(detectItemParent.getTitle());
			childHolderZore.tvCode.setText(detectItem.getTagid());
			childHolderZore.tvDetectMethod.setText(detectItem.getReference());
			childHolderZore.tvPosition.setText(detectItem.getPlace());
			childHolderZore.tvDetectMethod.setText(detectItem.getReference());
			childHolderZore.tvRecordValue.setText(detectItem.getRecord());
			childHolderZore.tvMalfValue.setText(detectItem.getContent());

//			disableRadioGroup(childHolderZore.rgFault);

			if (detectItem.getWithout() == 1) {
				// 无此项
				childHolderZore.rgFault.setItemChecked(2);
			} else if (detectItem.getCannot_test() == 1) {
				// 无法测试
				childHolderZore.rgFault.setItemChecked(3);
			} else {
				// 有此项
				if (TextUtils.isEmpty(detectItem.getFault())
						|| detectItem.getFault().equals("0")) {
					childHolderZore.rgFault.setItemChecked(0);
				} else {
					childHolderZore.rgFault.setItemChecked(1);
				}
			}
			if (detectItem.getWithout() == 1
					|| detectItem.getCannot_test() == 1) {
				childHolderZore.llDetail.setVisibility(View.GONE);
			} else {
				childHolderZore.llDetail.setVisibility(View.VISIBLE);
			}

			// 图片列表
			if (picList != null) {
				final String[] urls = new String[picList.size()];
				for (int i = 0; i < picList.size(); i++) {
					urls[i] = picList.get(i);
				}

				childHolderZore.gvPic
						.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View view, int position, long id) {
								Intent intent = new Intent(view.getContext(),
										ImagePagerActivity.class);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_URLS,
										urls);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_INDEX,
										position);
								view.getContext().startActivity(intent);
							}
						});
				PicsAdapter picsAdapter = new PicsAdapter(
						childHolderZore.gvPic.getContext(), picList,
						R.layout.item_detect_pic);
				childHolderZore.gvPic.setAdapter(picsAdapter);
			}
			
			
			break;
		case TYPE_1:
			// 有上次值、当前值
			final ChildHolderOne childHolderOne;
			if (convertView == null) {
				convertView = inflater.inflate(
						R.layout.item_detect_system_pre_cur_read, viewGroup,
						false);
				childHolderOne = new ChildHolderOne(convertView);
				convertView.setTag(childHolderOne);
			} else {
				childHolderOne = (ChildHolderOne) convertView.getTag();
			}
			childHolderOne.tvDetectTitle.setText(detectItemParent.getTitle());
			childHolderOne.tvCode.setText(detectItem.getTagid());
			childHolderOne.tvPosition.setText(detectItem.getPlace());
			childHolderOne.tvDetectMethod.setText(detectItem.getReference());
			childHolderOne.tvPre.setText(detectItem.getValue_1());
			childHolderOne.tvCur.setText(detectItem.getValue());
			childHolderOne.tvRecordValue.setText(detectItem.getRecord());
			childHolderOne.tvMalfValue.setText(detectItem.getContent());

			// 图片列表
			if (picList != null) {
				final String[] urls = new String[picList.size()];
				for (int i = 0; i < picList.size(); i++) {
					urls[i] = picList.get(i);
				}

				childHolderOne.gvPic
						.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View view, int position, long id) {
								Intent intent = new Intent(view.getContext(),
										ImagePagerActivity.class);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_URLS,
										urls);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_INDEX,
										position);
								view.getContext().startActivity(intent);
							}
						});
				PicsAdapter picsAdapter = new PicsAdapter(
						childHolderOne.gvPic.getContext(), picList,
						R.layout.item_detect_pic);
				childHolderOne.gvPic.setAdapter(picsAdapter);
			}
			
//			disableRadioGroup(childHolderOne.rgFault);
			
			if (detectItem.getWithout() == 1) {
				// 无此项
				childHolderOne.rgFault.setItemChecked(2);
			} else if (detectItem.getCannot_test() == 1) {
				// 无法测试
				childHolderOne.rgFault.setItemChecked(3);
			} else {
				// 有此项
				if (TextUtils.isEmpty(detectItem.getFault())
						|| detectItem.getFault().equals("0")) {
					childHolderOne.rgFault.setItemChecked(0);
				} else {
					childHolderOne.rgFault.setItemChecked(1);
				}
			}
			if (detectItem.getWithout() == 1
					|| detectItem.getCannot_test() == 1) {
				childHolderOne.llDetail.setVisibility(View.GONE);
			} else {
				childHolderOne.llDetail.setVisibility(View.VISIBLE);
			}
			break;
		case TYPE_2:
			// 有测试时间
			final ChildHolderTwo childHolderTwo;
			if (convertView == null) {
				convertView = inflater
						.inflate(R.layout.item_detect_system_time_read,
								viewGroup, false);
				childHolderTwo = new ChildHolderTwo(convertView);
				convertView.setTag(childHolderTwo);
			} else {
				childHolderTwo = (ChildHolderTwo) convertView.getTag();
			}
			childHolderTwo.tvDetectTitle.setText(detectItemParent.getTitle());
			childHolderTwo.tvCode.setText(detectItem.getTagid());
			childHolderTwo.tvPosition.setText(detectItem.getPlace());
			childHolderTwo.tvDetectMethod.setText(detectItem.getReference());
			childHolderTwo.tvStartDate.setText(TextUtils.isEmpty(detectItem.getValue_1())?"":DateUtils.stampToDate(detectItem.getValue_1()));
			childHolderTwo.tvEndDate.setText(TextUtils.isEmpty(detectItem.getValue_2())?"":DateUtils.stampToDate(detectItem.getValue_2()));
			childHolderTwo.tvRecordValue.setText(detectItem.getRecord());
			childHolderTwo.tvMalfValue.setText(detectItem.getContent());

			// 图片列表
			if (picList != null) {
				final String[] urls = new String[picList.size()];
				for (int i = 0; i < picList.size(); i++) {
					urls[i] = picList.get(i);
				}

				childHolderTwo.gvPic
						.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View view, int position, long id) {
								Intent intent = new Intent(view.getContext(),
										ImagePagerActivity.class);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_URLS,
										urls);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_INDEX,
										position);
								view.getContext().startActivity(intent);
							}
						});
				PicsAdapter picsAdapter = new PicsAdapter(
						childHolderTwo.gvPic.getContext(), picList,
						R.layout.item_detect_pic);
				childHolderTwo.gvPic.setAdapter(picsAdapter);
			}
			
			if (detectItem.getWithout() == 1) {
				// 无此项
				childHolderTwo.rgFault.setItemChecked(2);
			} else if (detectItem.getCannot_test() == 1) {
				// 无法测试
				childHolderTwo.rgFault.setItemChecked(3);
			} else {
				// 有此项
				if (TextUtils.isEmpty(detectItem.getFault())
						|| detectItem.getFault().equals("0")) {
					childHolderTwo.rgFault.setItemChecked(0);
				} else {
					childHolderTwo.rgFault.setItemChecked(1);
				}
			}
			if (detectItem.getWithout() == 1
					|| detectItem.getCannot_test() == 1) {
				childHolderTwo.llDetail.setVisibility(View.GONE);
			} else {
				childHolderTwo.llDetail.setVisibility(View.VISIBLE);
			}
			break;
		case TYPE_4:
			// 有上次值、当前值
			final ChildHolderFour childHolderFour;
			if (convertView == null) {
				convertView = inflater.inflate(
						R.layout.item_detect_system_cur_read, viewGroup, false);
				childHolderFour = new ChildHolderFour(convertView);
				convertView.setTag(childHolderFour);
			} else {
				childHolderFour = (ChildHolderFour) convertView.getTag();
			}
			childHolderFour.tvDetectTitle.setText(detectItemParent.getTitle());
			childHolderFour.tvCode.setText(detectItem.getTagid());
			childHolderFour.tvPosition.setText(detectItem.getPlace());
			childHolderFour.tvDetectMethod.setText(detectItem.getReference());
			childHolderFour.tvCur.setText(detectItem.getValue());
			childHolderFour.tvRecordValue.setText(detectItem.getRecord());
			childHolderFour.tvMalfValue.setText(detectItem.getContent());
			
			// 图片列表
			if (picList != null) {
				final String[] urls = new String[picList.size()];
				for (int i = 0; i < picList.size(); i++) {
					urls[i] = picList.get(i);
				}

				childHolderFour.gvPic
						.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View view, int position, long id) {
								Intent intent = new Intent(view.getContext(),
										ImagePagerActivity.class);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_URLS,
										urls);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_INDEX,
										position);
								view.getContext().startActivity(intent);
							}
						});
				PicsAdapter picsAdapter = new PicsAdapter(
						childHolderFour.gvPic.getContext(), picList,
						R.layout.item_detect_pic);
				childHolderFour.gvPic.setAdapter(picsAdapter);
			}
			
			if (detectItem.getWithout() == 1) {
				// 无此项
				childHolderFour.rgFault.setItemChecked(2);
			} else if (detectItem.getCannot_test() == 1) {
				// 无法测试
				childHolderFour.rgFault.setItemChecked(3);
			} else {
				// 有此项
				if (TextUtils.isEmpty(detectItem.getFault())
						|| detectItem.getFault().equals("0")) {
					childHolderFour.rgFault.setItemChecked(0);
				} else {
					childHolderFour.rgFault.setItemChecked(1);
				}
			}
			if (detectItem.getWithout() == 1
					|| detectItem.getCannot_test() == 1) {
				childHolderFour.llDetail.setVisibility(View.GONE);
			} else {
				childHolderFour.llDetail.setVisibility(View.VISIBLE);
			}
			break;
		case TYPE_5:
			final ChildHolderFive childHolderFive;
			if (convertView == null) {
				convertView = inflater.inflate(
						R.layout.item_detect_system_point_read, viewGroup,
						false);
				childHolderFive = new ChildHolderFive(convertView);
				convertView.setTag(childHolderFive);
			} else {
				childHolderFive = (ChildHolderFive) convertView.getTag();
			}
			childHolderFive.tvDetectTitle.setText(detectItemParent.getTitle());
			childHolderFive.tvCode.setText(detectItem.getTagid());
			childHolderFive.tvPosition.setText(detectItem.getPlace());
			childHolderFive.tvDetectMethod.setText(detectItem.getReference());
			childHolderFive.tvNormalValue.setText(detectItem.getValue_1());
			childHolderFive.tvErrorValue.setText(detectItem.getValue_2());
			childHolderFive.tvRecordValue.setText(detectItem.getRecord());
			childHolderFive.tvMalfValue.setText(detectItem.getContent());

			// 图片列表
			if (picList != null) {
				final String[] urls = new String[picList.size()];
				for (int i = 0; i < picList.size(); i++) {
					urls[i] = picList.get(i);
				}

				childHolderFive.gvPic
						.setOnItemClickListener(new OnItemClickListener() {

							@Override
							public void onItemClick(AdapterView<?> parent,
									View view, int position, long id) {
								Intent intent = new Intent(view.getContext(),
										ImagePagerActivity.class);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_URLS,
										urls);
								intent.putExtra(
										ImagePagerActivity.EXTRA_IMAGE_INDEX,
										position);
								view.getContext().startActivity(intent);
							}
						});
				PicsAdapter picsAdapter = new PicsAdapter(
						childHolderFive.gvPic.getContext(), picList,
						R.layout.item_detect_pic);
				childHolderFive.gvPic.setAdapter(picsAdapter);
			}
			
//			disableRadioGroup(childHolderFive.rgFault);
			
			if (detectItem.getWithout() == 1) {
				// 无此项
				childHolderFive.rgFault.setItemChecked(2);
			} else if (detectItem.getCannot_test() == 1) {
				// 无法测试
				childHolderFive.rgFault.setItemChecked(3);
			} else {
				// 有此项
				if (TextUtils.isEmpty(detectItem.getFault())
						|| detectItem.getFault().equals("0")) {
					childHolderFive.rgFault.setItemChecked(0);
				} else {
					childHolderFive.rgFault.setItemChecked(1);
				}
			}
			if (detectItem.getWithout() == 1
					|| detectItem.getCannot_test() == 1) {
				childHolderFive.llDetail.setVisibility(View.GONE);
			} else {
				childHolderFive.llDetail.setVisibility(View.VISIBLE);
			}
			break;
		}

		return convertView;

	}

	@Override
	public boolean isChildSelectable(int i, int i1) {
		return true;
	}

	class GroupHolder {
		TextView mGroupTitleTv;
		TextView tvMore;

		public GroupHolder(View view) {
			mGroupTitleTv = (TextView) view.findViewById(R.id.groupTitle);
			tvMore = (TextView) view.findViewById(R.id.tvMore);
		}
	}

	class ChildHolderZore {
		TextView tvCode;
		TextView tvPosition;
		TextView tvDetectMethod;
		TextView tvStatus;
		TextView tvRecordValue;
		TextView tvMalfValue;
		GridView gvPic;
		MultiLineRadioGroup rgFault;
		LinearLayout llDetail;
		TextView tvDetectTitle;

		public ChildHolderZore(View convertView) {
			tvCode = (TextView) convertView.findViewById(R.id.tvCode);
			tvPosition = (TextView) convertView.findViewById(R.id.tvPosition);
			tvDetectMethod = (TextView) convertView
					.findViewById(R.id.tvDetectMethod);
			tvRecordValue = (TextView) convertView
					.findViewById(R.id.tvRecordValue);
			tvMalfValue = (TextView) convertView
					.findViewById(R.id.tvMalfValue);
			gvPic = (GridView) convertView.findViewById(R.id.gvPic);
			rgFault = (MultiLineRadioGroup) convertView.findViewById(R.id.rgFault);
			llDetail = (LinearLayout) convertView.findViewById(R.id.llDetail);
			tvDetectTitle = (TextView) convertView.findViewById(R.id.tvDetectTitle);
		}
	}

	class ChildHolderOne {
		TextView tvCode;
		TextView tvPosition;
		TextView tvDetectMethod;
		TextView tvPre;
		TextView tvCur;
		TextView tvRecordValue;
		TextView tvMalfValue;
		GridView gvPic;
		MultiLineRadioGroup rgFault;
		LinearLayout llDetail;
		TextView tvDetectTitle;

		public ChildHolderOne(View convertView) {
			tvCode = (TextView) convertView.findViewById(R.id.tvCode);
			tvPosition = (TextView) convertView.findViewById(R.id.tvPosition);
			tvDetectMethod = (TextView) convertView
					.findViewById(R.id.tvDetectMethod);
			tvPre = (TextView) convertView.findViewById(R.id.tvPre);
			tvCur = (TextView) convertView.findViewById(R.id.tvCur);
			tvRecordValue = (TextView) convertView
					.findViewById(R.id.tvRecordValue);
			tvMalfValue = (TextView) convertView
					.findViewById(R.id.tvMalfValue);
			gvPic = (GridView) convertView.findViewById(R.id.gvPic);
			rgFault = (MultiLineRadioGroup) convertView.findViewById(R.id.rgFault);
			llDetail = (LinearLayout) convertView.findViewById(R.id.llDetail);
			tvDetectTitle = (TextView) convertView.findViewById(R.id.tvDetectTitle);
		}
	}

	class ChildHolderTwo {
		TextView tvCode;
		TextView tvPosition;
		TextView tvDetectMethod;
		TextView tvStartDate;
		TextView tvEndDate;
		TextView tvRecordValue;
		TextView tvMalfValue;
		GridView gvPic;
		MultiLineRadioGroup rgFault;
		LinearLayout llDetail;
		TextView tvDetectTitle;

		public ChildHolderTwo(View convertView) {
			tvCode = (TextView) convertView.findViewById(R.id.tvCode);
			tvPosition = (TextView) convertView.findViewById(R.id.tvPosition);
			tvDetectMethod = (TextView) convertView
					.findViewById(R.id.tvDetectMethod);
			tvStartDate = (TextView) convertView.findViewById(R.id.tvStartDate);
			tvEndDate = (TextView) convertView.findViewById(R.id.tvEndDate);
			tvRecordValue = (TextView) convertView
					.findViewById(R.id.tvRecordValue);
			tvMalfValue = (TextView) convertView
					.findViewById(R.id.tvMalfValue);
			gvPic = (GridView) convertView.findViewById(R.id.gvPic);
			rgFault = (MultiLineRadioGroup) convertView.findViewById(R.id.rgFault);
			llDetail = (LinearLayout) convertView.findViewById(R.id.llDetail);
			tvDetectTitle = (TextView) convertView.findViewById(R.id.tvDetectTitle);
		}
	}

	class ChildHolderFour {
		TextView tvCode;
		TextView tvPosition;
		TextView tvDetectMethod;
		TextView tvCur;
		TextView tvRecordValue;
		TextView tvMalfValue;
		GridView gvPic;
		MultiLineRadioGroup rgFault;
		LinearLayout llDetail;
		TextView tvDetectTitle;

		public ChildHolderFour(View convertView) {
			tvCode = (TextView) convertView.findViewById(R.id.tvCode);
			tvPosition = (TextView) convertView.findViewById(R.id.tvPosition);
			tvDetectMethod = (TextView) convertView
					.findViewById(R.id.tvDetectMethod);
			tvCur = (TextView) convertView.findViewById(R.id.tvCur);
			tvRecordValue = (TextView) convertView
					.findViewById(R.id.tvRecordValue);
			tvMalfValue = (TextView) convertView
					.findViewById(R.id.tvMalfValue);
			gvPic = (GridView) convertView.findViewById(R.id.gvPic);
			rgFault = (MultiLineRadioGroup) convertView.findViewById(R.id.rgFault);
			llDetail = (LinearLayout) convertView.findViewById(R.id.llDetail);
			tvDetectTitle = (TextView) convertView.findViewById(R.id.tvDetectTitle);
		}
	}

	class ChildHolderFive {
		TextView tvCode;
		TextView tvPosition;
		TextView tvDetectMethod;
		TextView tvNormalValue;
		TextView tvErrorValue;
		TextView tvRecordValue;
		TextView tvMalfValue;
		GridView gvPic;
		MultiLineRadioGroup rgFault;
		LinearLayout llDetail;
		TextView tvDetectTitle;

		public ChildHolderFive(View convertView) {
			tvCode = (TextView) convertView.findViewById(R.id.tvCode);
			tvPosition = (TextView) convertView.findViewById(R.id.tvPosition);
			tvDetectMethod = (TextView) convertView
					.findViewById(R.id.tvDetectMethod);
			tvNormalValue = (TextView) convertView
					.findViewById(R.id.tvNormalValue);
			tvErrorValue = (TextView) convertView
					.findViewById(R.id.tvErrorValue);
			tvRecordValue = (TextView) convertView
					.findViewById(R.id.tvRecordValue);
			tvMalfValue = (TextView) convertView
					.findViewById(R.id.tvMalfValue);
			gvPic = (GridView) convertView.findViewById(R.id.gvPic);
			rgFault = (MultiLineRadioGroup) convertView.findViewById(R.id.rgFault);
			llDetail = (LinearLayout) convertView.findViewById(R.id.llDetail);
			tvDetectTitle = (TextView) convertView.findViewById(R.id.tvDetectTitle);
		}
	}

	@Override
	public int getChildType(int groupPosition, int childPosition) {
		String kind = mList.get(groupPosition).getChildList()
				.get(childPosition).getKind();
		if (Integer.parseInt(kind) == 0) {
			// 有当前状态的选项
			return TYPE_0;
		} else if (Integer.parseInt(kind) == 1) {
			// 上次值、当前值
			return TYPE_1;
		} else if (Integer.parseInt(kind) == 2) {
			// 测试时间的
			return TYPE_2;
		} else if (Integer.parseInt(kind) == 3) {
			return TYPE_3;
		} else if (Integer.parseInt(kind) == 4) {
			return TYPE_4;
		} else if (Integer.parseInt(kind) == 5) {
			// 正常点数、异常点数
			return TYPE_5;
		}

		try {
			throw new Exception("kind没有没有等于" + Integer.parseInt(kind) + "的类别");
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return TYPE_0;
	}

	@Override
	public int getChildTypeCount() {
		return 10;
	}

	public ArrayList<DetectItemParent> getmList() {
		return mList;
	}

	public void disableRadioGroup(RadioGroup testRadioGroup) {
		for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
			testRadioGroup.getChildAt(i).setEnabled(false);
		}
	}
}